<?php
require(dirname(__FILE__)."/../inc/common.inc.php");
admin(0);
$list=array();
$list['data']=array();



$query = $db->query("select id,name from {$pre}department  where 1=1 order  by id asc");
while($rs = $db->fetch_array($query)){  
	$list1=array();
	$list1['id']='d'.$rs['id'];
	$list1['deptname']=$rs['name'];
	
	$list4=array();

	
	$query1 = $db->query("select id,name from {$pre}personnel	 where status='1'  and  dept='{$rs['id']}'  order by id asc");
	while($rs1 = $db->fetch_array($query1)){
		
		$list2['id']=$rs1['id'];
		$list2['deptname']=$rs1['name'];
		$list2['children']=array();
		
		$list4[]=$list2;
		
	}
	$list1['children']=$list4;
	$list['data'][]=$list1;
}
echo json_encode($list);
exit;
?>